[Top] [Prev] [Next] [Bottom] [Contents]

SutNewListSize

Returns a pSutList, which is a pointer to a SutList structure.

Synopsis

#include "SutList.h"
pSutList SutNewListSize(int size);

Arguments

size
Specifies that the initial size of the SutList will be + 1. The minimum size is 4.

Return Values

Returns a pSutList, which is a pointer to a SutList structure.

Description

SutNewListSize returns a pSutList, a pointer to a SutList structure. The parameter, size, specifies the initial size of the SutList. SutNewList makes a list with an initial size of 20, which will grow as needed, and this growth can be inefficient. Use SutNewListSize to make a small list if that's all you will need; it will save memory. Use SutNewListSize to make a very large list and save it from having to reallocate memory if you anticipate a large list. See the caution under SutDestroyList. The SutList structure and related functions manage a dynamically sized array of void pointers which can be used as a generic container for C/C++ programmers. The list must be deallocated with SutDeleteList() or SutDestroyList().

Example

#include "SutList.h"
#include <stdio.h>
pSutList list;
int i, size;
char *str;
char* str1 = "Hello";
char* str2 = "World";
list = SutNewListSize(3);
SutAddList(list, str1);
SutAddList(list, str2);
size = SutSizList(list);
for (i=0; i<size; i++)
{
	str = (char*) SutGetNList(list, i);
	fprintf(stderr, "%s\n", str);
}
SutDeleteList(list);

See Also



[Top] [Prev] [Next] [Bottom] [Contents]

info@bluestone.com
Copyright © 1997, Bluestone. All rights reserved.